import qs from 'qs'
import request from '@/utils/request'

//与conpany有关的api

const myCompany = {
  // 我的发布
  reqMyPublishList(params) {
    return request({
      url: 'api/jobs/lists/owner',
      method: 'get',
      hideloading: false,
      params: {
        pageIndex: params.pageIndex,
        pageSize: params.pageSize
      }
    })
  }
}

//公司信息，发布的需求
export function reqCompanyObj(id) {
  return request({
    url: `/api/jobs/get?id=${id}`,
    method: 'get',
    hideloading: true
  })
}

// 我的公司信息招聘列表（仅用于我的公司）
export function reqHomeCompanyLists(params) {
  return request({
    url: `/api/jobs/lists/ownerList?status=${params.status}`,
    method: 'get',
    hideloading: true
  })
}

//公司发布的招聘列表
export function reqCompanyLists(params) {
  return request({
    url: `/api/jobs/lists/owner`,
    method: 'get',
    hideloading: false,
    params
  })
}

//公司信息，排序招聘列表
export function sortCompanyLists(id) {
  return request({
    url: `/api/jobs/lists/owner?orderItem=${id}`,
    method: 'get',
    hideloading: true
  })
}
//获取我的关注接口，区分全职、兼职
export function getcollectLists(id) {
  if (id) {
    return request({
      url: `/api/jobs/job/getcollect?job_category_id=${id}`,
      method: 'get',
      hideloading: true
    })
  } else {
    return request({
      url: `/api/jobs/job/getcollect`,
      method: 'get',
      hideloading: true
    })
  }
}
//公司信息，薪资招聘列表
export function salaryCompanyLists(params) {
  return request({
    url: `/api/jobs/lists/owner?minsalary=${params.minsalary}&maxsalary=${params.maxsalary}`,
    method: 'get',
    hideloading: true
  })
}
//当为全部的时候
export function allCompanyLists() {
  return request({
    url: `/api/jobs/lists/owner`,
    method: 'get',
    hideloading: true
  })
}

//公司信息，附近招聘列表
export function nearCompanyLists(id) {
  return request({
    url: `/api/jobs/lists/owner?nearby=${id}`,
    method: 'get',
    hideloading: true
  })
}

//公司信息，筛选招聘列表
export function screenCompanyLists(params) {
  return request({
    url: `/api/jobs/lists/owner?classproperties=${params.classproperties}&jobbattributes=${params.jobbattributes}&benefits=${params.benefits}&paymode=${params.paymode}&payday=${params.payday}&payMoneyDetailDate=${params.payMoneyDetailDate}&createTime=${params.createTime}`,
    method: 'get',
    hideloading: true
  })
}

//公司信息，关键字查询的招聘列表
export function searchKeywords(id) {
  return request({
    url: `/api/jobs/lists/owner?keyword=${id}`,
    method: 'get',
    hideloading: true
  })
};

//报名信息首页点击查看详情数据
export function reqGetManagement(params) {
  return request({
    url: `/api/jobs/lists/ownerUser`,
    method: 'get',
    params
  })
}
//工作信息首页点击查看详情数据
export function reqGetApply(params) {
  return request({
    url: `/api/jobs/get_apply`,
    method: 'get',
    hideloading: true,
    params
  })
};


//在招、停招的切换
export function reqChangeJobStatus(params) {
  return request({
    url: `/api/jobs/switch`,
    method: 'post',
    data: qs.stringify(params),
    hideloading: true,
  })
}


// 获取报道码
export function reqGetBdCode(params) {
  return request({
    url: `/api/jobs/exten/baodaocode/get`,
    method: 'get',
    params
  })
};

// 设置报道码
export function reqUpdateBdCode(params) {
  return request({
    url: `/api/jobs/exten/baodaocode`,
    method: 'post',
    data: qs.stringify(params)
  })
};

//更新报名相关信息接口
export function reqSaveCompanyApplyUpdate(params) {
  return request({
    url: `/api/jobs/apply/upstate`,
    method: 'post',
    data: qs.stringify(params)
  })
}
//获取单个职位信息
export function getJobData(id) {
  return request({
    url: `/api/jobs/get?id=${id}`,
    method: 'get'
  })
}

/*
 * @Descripttion: 与conpany有关的api
 * @Author: liuxiaoling
 * @Date: 2021-03-22 19:07:54
 * @LastEditors: liuxiaoling
 * @LastEditTime: 2021-04-17 17:24:00
 */

const company = {
  //公司信息，发布的需求
  reqCompanyObj(id) {
    return request({
      url: `/api/jobs/get?id=${id}`,
      method: 'get',
      hideloading: true
    })
  },
  //Begin Add By RenQingBin 2022-01-03
  //员工借支信息的详细清单
  reqGetLendJobInfo(params) {
    return request({
      url: `/api/advance/getLendJobInfo`,  //新的方法
      //method: 'post',  //原来的
      method: 'get',  //新的
      //data: qs.stringify(params)  //原来的

      params,
      hideloading: false
    })
  },
  //End Add By RenQingBin 2022-01-03
  //Begin Upd By RenQingBin 2021-12-12
  //借支信息的职位列表
  reqGetMyCompanyAdvanceInfo(params) {
    return request({
      url: `/api/advance/getMyCompanyAdvanceInfo`,  //新的方法
      method: 'get',  //新的
      params,
      hideloading: false
    })
  },
  //公司借支信息详情
  reqGetAdvanceBill(params) {
    return request({
      url: `/api/advance/getAdvancePositionBill`,
      method: 'get',
      params,
      hideloading: false
    })
  },
  //End Upd By RenQingBin 2021-12-12
  //公司工资信息详情
  reqGetSalaryInfo(params) {
    return request({
      url: `/api/salary/GetSalaryInfo`,
      method: 'post',
      data: qs.stringify(params)
    })
  },
  //创建借支单
  reqCreateAdvanceBill(params) {
    return request({
      url: `/api/advance/createAdvanceBill`,
      method: 'post',
      data: qs.stringify(params)
    })
  },
  // 拒绝借支申请
  reqRejectLendMoney(params){
    return request({
      url: `/api/advance/refuseUserApplyAdvance`,
      method: 'post',
      data: params
    })
  },

  // 同意用户借支申请(支付借支金额)
  agreeUserApplyAdvance(params){
    return request({
      url: `/api/advance/agreeUserApplyAdvance`,
      method: 'post',
      data: params
    })
  },

  //获取自己公司信息
  reqGetCompanyMes(params) {
    return request({
      url: `/api/company/myself`,
      method: 'get',
      hideloading: true,
      // params: params
    })
  },
  //保存公司信息
  reqSaveCompanyMes(params) {
    return request({
      url: `/api/company/save`,
      method: 'post',
      data: qs.stringify(params)
    })
  },
  //工作信息首页数据
  reqGetlistsOwner() {
    return request({
      url: `/api/jobs/lists/owner`,
      method: 'get',
      hideloading: true
    })
  },
  //工资信息
  reqGetOnJoblistsOwner(params) {
    return request({
      url: `/api/jobs/lists/getOnJobList`,
      method: 'get',
      params: params,
    })
  },
  reqGetSalaryJobList(params) {
    return request({
      url: `/api/jobs/lists/getSalaryJobList`,
      method: 'get',
      params: params,
    })
  },

  // 查询借支记录
  getAdvanceBillAll(params) {
    return request({
      url: '/api/advance/getAdvanceBillAll',
      method: 'post',
      data: params
    })
  },

  // 工资信息相关api
  // 获取工资条模板
  getSalaryCategory(params) {
    return request({
      url: '/api/salary/getSalaryCategory',
      method: 'post',
      data: params
    })
  },
  // 工资条模板输入
  CreateSalaryCategoryInfo(params) {
    return request({
      url: '/api/salary/CreateSalaryCategoryInfo',
      method: 'post',
      data: params
    })
  },
  // 设置默认工资条
  setdefaultSalaryCategory(params) {
    return request({
      url: '/api/salary/setdefaultSalaryCategory',
      method: 'post',
      data: params
    })
  },
  // 设置为招聘工资模板
  setSalaryCategoryToJob(params) {
    return request({
      url: '/api/salary/setSalaryCategoryToJob',
      method: 'post',
      data: params
    })
  },
  // 创建工资条
  createSalaryInfo(params) {
    return request({
      url: 'api/salary/createSalaryInfo',
      method: 'post',
      data: params
    })
  },

  // 获取人员最后一次未发的工资
  getLastNotCheckSalaryInfo(params) {
    return request({
      url: '/api/salary/getLastNotCheckSalaryInfo',
      method: 'post',
      data: params
    })
  },

  // 更新工资信息
  updateSalaryInfo(params) {
    return request({
      url: '/api/salary/updateSalaryInfo',
      method: 'post',
      data: params
    })
  },

  // 支付工资
  SalaryEnter(params) {
    return request({
      url: '/api/salary/SalaryEnter',
      method: 'post',
      data: params
    })
  },

  // 获取指定岗位指定员工的工资条列表
  GetSalarySheetByJobUserId(params) {
    return request({
      url: '/api/salary/GetSalarySheetByJobUserId',
      method: 'post',
      data: params,
      hideloading: true
    })
  },

  // 获取指定工资条详细信息
  getSalaryInfoById(params) {
    return request({
      url: '/api/salary/getSalaryInfoById',
      method: 'post',
      data: params,
      hideloading: true
    })
  },

  // 获取公司员工借支信息
  getUserApplyAdvance(params) {
    return request({
      url: '/api/advance/getUserApplyAdvance',
      method: 'post',
      data: params
    })
  },

  // 获取公司员工个人最新借支信息
  getUserLatestAdvance(params) {
    return request({
      url: '/api/advance/getUserLatestAdvance',
      method: 'post',
      data: params
    })
  },

  // 代招费设置工作时长
  setWorkload(params) {
    return request({
      url: '/api/salary/SetWorkload',
      method: 'post',
      data: params
    })
  },

  // 支付代招费
  payForGenerationHiringFee(params) {
    return request({
      url: '/api/salary/PayForGenerationHiringFee',
      method: 'post',
      data: params
    })
  },

  // 获取代招费列表
  getGenerationHiringFeeList(params) {
    return request({
      url: '/api/salary/GetGenerationHiringFeeList',
      method: 'post',
      data: params
    })
  },


  // 合作费收到、支付的记录
  getCooperationPayFeeList(params) {
    return request({
      url: '/api/jobs/cooperation/paylist',
      method: 'get',
      params
    })
  },

  // 获取我的公司职位列表分页
  getMyCompanyJobPage: params =>
    request.get('/api/jobs/lists/ownerlist', {
      hideloading: false,
      params: params
    }),
}

export default company
